/**
 * 颜色组件
 */

(function ($) {

    //实现类
    var Color = function ($ele, ops) {
        $ele.minicolors(ops);
    };

    //插件定义
    jx.plugin({
        name: 'jxcolor',
        instance: function ($ele, ops) {
            return Color($ele, ops);
        },
        defaults: {
            control: 'hue',
            defaultValue: '',
            format: 'hex',
            keywords: '',
            inline: false,
            letterCase: 'lowercase',
            position: 'bottom left',
            swatches: [],
            theme: 'bootstrap'
        }
    });

    //注册依赖
    jx.onBeforeInit(function (e) {
        if (document.querySelector('.jxcolor')) {
            jx.depend('minicolor');
        }
    });

    //实例化
    jx.onInit(function (e) {
        $(e.target).find('.jxcolor').jxcolor();
    });

}(jQuery));
